package com.hzncc.flowable_diboot.flowable.event.payment;

import com.diboot.core.util.ContextHolder;
import com.hzncc.flowable_diboot.constans.BpmnModelConstants;
import com.hzncc.flowable_diboot.constans.ContractModelKeyConstants;
import com.hzncc.flowable_diboot.flowable.event.BpmProcessInstanceStatusEvent;
import com.hzncc.flowable_diboot.flowable.event.BpmProcessInstanceStatusEventListener;
import com.hzncc.flowable_diboot.payment.service.PaymentContractService;
import com.hzncc.flowable_diboot.payment.service.impl.PaymentContractServiceImpl;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;

@Component
public class PaymentContractStatusListener extends BpmProcessInstanceStatusEventListener {

    @Override
    protected String getProcessDefinitionKey() {
        return ContractModelKeyConstants.PAYMENT_CONTRACT_SUBMIT;
    }

    @Override
    protected void onEvent(BpmProcessInstanceStatusEvent event) {

        PaymentContractService paymentContractService = ContextHolder.getBean(PaymentContractServiceImpl.class);
        paymentContractService.updatePaymentContractStatus(event.getBusinessKey(), String.valueOf(event.getStatus()));

    }
}
